<template>
  <div class="side">
    <div class="side-head">参数优化</div>
    <div class="side-choose"></div>
    <div class="side-echarts1"></div>
    <hr>
    <div class="side-echarts2"></div>
    <hr>
    <div class="side-echarts3"></div>
  </div>
</template>
    
    <script>
export default {
  mounted() {
    this.initEcharts();
  },
  data() {
    return {
      // 配置项
      option1: {
        // 标题
        title:{
            show:true,
            text:'超稠油蒸汽处理液位',
            textStyle:{
                color:'white',
                fontSize:20,
            }
        },
        // 标头
        legend: {
          data: ["液位"],
          textStyle: {
            fontSize: 12,
            color: "white",
          },
        },
        // 网格线位置
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        // 保存为图片
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        // 拐点颜色
        itemStyle: {
          borderColor: "#E9CD4B",
        },
        // 字体颜色
        textStyle: {
          color: "#ff9d16",
        },
        xAxis: {
          type: "category",
          data: ["13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [2.1, 2.3, 3.1, 4.1, 4.2, 5.1, 6.2],
            type: "line",
            name: "液位",
            // 显示数值
            itemStyle: { normal: { label: { show: true } } },
            // 线条颜色
            lineStyle: {
              width: 3,
              color: "#ff9d16",
            },
          },
        ],
      },
      option2: {
        // 标题
        title:{
            show:true,
            text:'输油泵外输压力',
            textStyle:{
                color:'white',
                fontSize:20,
            }
        },
        // 标头
        legend: {
          data: ["压力"],
          textStyle: {
            fontSize: 12,
            color: "white",
          },
        },
        // 网格线位置
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        // 保存为图片
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        // 拐点颜色
        itemStyle: {
          borderColor: "#E9CD4B",
        },
        // 字体颜色
        textStyle: {
          color: "#ff9d16",
        },
        xAxis: {
          type: "category",
          data: ["13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [2.1, 2.3, 3.1, 4.1, 4.2, 5.1, 6.2],
            type: "line",
            name: "压力",
            // 显示数值
            itemStyle: { normal: { label: { show: true } } },
            // 线条颜色
            lineStyle: {
              width: 3,
              color: "#ff9d16",
            },
          },
        ],
      },
      option3: {
        // 标题
        title:{
            show:true,
            text:'输油泵外输温度',
            textStyle:{
                color:'white',
                fontSize:20,
            }
        },
        // 标头
        legend: {
          data: ["温度"],
          textStyle: {
            fontSize: 12,
            color: "white",
          },
        },
        // 网格线位置
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        // 保存为图片
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        // 拐点颜色
        itemStyle: {
          borderColor: "#E9CD4B",
        },
        // 字体颜色
        textStyle: {
          color: "#ff9d16",
        },
        xAxis: {
          type: "category",
          data: ["13:00", "13:10", "13:20", "13:30", "13:40", "13:50", "14:00"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            data: [2.1, 2.3, 3.1, 4.1, 4.2, 5.1, 6.2],
            type: "line",
            name: "温度",
            // 显示数值
            itemStyle: { normal: { label: { show: true } } },
            // 线条颜色
            lineStyle: {
              width: 3,
              color: "#ff9d16",
            },
          },
        ],
      },
    };
  },

  methods: {
    // 初始化表格
    initEcharts() {
        // 表1
      var myChart = this.$echarts.init(
        document.querySelector(".side-echarts1")
      );
      myChart.setOption(this.option1);

      // 表2
      var myChart2 = this.$echarts.init(
        document.querySelector(".side-echarts2")
      );
      myChart2.setOption(this.option2);

      // 表3
      var myChart3 = this.$echarts.init(
        document.querySelector(".side-echarts3")
      );
      myChart3.setOption(this.option3);

      // 适应缩放比
      window.addEventListener("resize", function () {
        myChart.resize();
        myChart2.resize();
        myChart3.resize();
      });
    },
  },
};
</script>
    
    <style scoped>
/* 头部 */
.side-head {
  height: 50px;
  background-image: url(../../../assets/img/tankLevel1.svg);
  background-size: cover;
  background-position: 50% 50%;
  background-repeat: no-repeat;

  padding-left: 10px;

  color: rgba(117, 249, 253, 1);
  font-size: 20px;
  font-family: Arial;
  font-weight: 700;
  line-height: 50px;
}
/* 图表 */
.side-echarts1,.side-echarts2,.side-echarts3 {
  width: 100%;
  height: 200px;
  /* background-color: pink; */

  margin-top: 20px;
  margin-bottom: 20px;
}
/* 文字 */
.side-text {
  height: 60px;
  /* background-color: pink; */
  margin-top: 20px;
  padding-left: 20px;
  padding-top: 5px;

  color: white;
  font-size: 1em;
}
</style>